package cn.test.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;

import java.net.SocketAddress;

/***
 *
 *
 * @Author: SJie
 * Date: 2019/12/19 下午5:44
 * Description: 
 *
 */

public class ClientHandlerOut1 extends ChannelOutboundHandlerAdapter {


    @Override
    public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
        System.out.println("clientOut1:"+"bind");
        super.bind(ctx, localAddress, promise);
    }

    @Override
    public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
        System.out.println("clientOut1:"+"connent");
        super.connect(ctx,remoteAddress,localAddress,promise);
    }

    @Override
    public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        super.disconnect(ctx, promise);
    }

    @Override
    public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        super.close(ctx, promise);
    }

    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        System.out.println("clientOut1:"+"read");
//        System.out.println("clientOut1:"+ctx.channel().id().asLongText());
//        ctx.writeAndFlush(ctx.channel().id().asLongText());
        super.read(ctx);
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        System.out.println("clientOut1:"+"write");
//        System.out.println("clientOut1:"+msg.toString());
        super.write(ctx,msg,promise);
    }
}
